<?php
/*
 * MY Guitar Tabs and Chords Blog index file
 * 
 *  @version 1.0;
 */

// Define Directory Separator and define APP_PATH to current folder

define('DS', DIRECTORY_SEPARATOR); // Define DIRECTORY_SEPARATOR
define('APP_PATH', dirname(__FILE__) . DS); // DEFINE APPLICATION_PATH;
ini_set('display_errors', true); // INI SET
error_reporting(E_ALL);

// Now include Config File
if (file_exists(APP_PATH . 'includes' . DS . 'config.php')) {
    include(APP_PATH . 'includes' . DS . 'config.php');
} else {
    echo 'No config File is Defined. Please reinstall the system.';
    die();
}
// Invoke Load file
include(INCLUDE_PATH . 'load.php');
// Now determine the request and run the specific code to handle request
rewrite::newInstance()->init();
//Params::setParam('https', true);
//echo site_url();
$page = params::getParam('page');
switch ($page) {
    case 'item':
        include code_path() . 'item.php';
        $app = new Application();
        $app->run();
        break;
    
    case 'categories':
        include code_path() . 'category.php';
        $app = new Application();
        $app->run();
        break;
    
    case 'location':
        include code_path() . 'location.php';
        $app = new Application();
        $app->run();
        break;
    
    case 'user':
        include code_path() . 'user.php';
        $app = new Application();
        $app->run();
        break;
    
    case 'search':
        include include_path() . 'search.php';
        $app = new Application();
        $app->run();
        break;
    
    case 'ajax':
        include include_path() . 'ajax.php';
        $app = new Appilcation();
        $app->run();
        break;
    
    case '404':
        header("HTTP/1.0 404 Not Found");
        echo '404';
        break;
    
    default:
        include (code_path() . 'home.php');
        $app = new Application();
        $app->run();
}